﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Business
{
    public partial class Region
    {
        public static Common.ERROR_CODE.ERROR_CODE_ITEMS_SELECT getRegionForFrm(ref string messageError, ref List<Region> listRegion)
        {
            DataClassesDataContext context = null;
            try
            {
                context = new DataClassesDataContext(Common.Global.GetConnectionInfo().ConnectionStringSQL);
                var query = context.Regions.Where(p => (p.RegionLevel == 3 || p.RegionLevel == 4) && (p.Status == 1));
                listRegion = query.ToList();
                messageError = "";
                return Common.ERROR_CODE.ERROR_CODE_ITEMS_SELECT.SUCCESS;
            }
            catch
            {
                messageError = Common.EnumUtils.stringValueOf(Common.ERROR_CODE.ERROR_CODE_ITEMS_SELECT.SYSTEM_ERROR);
                return Common.ERROR_CODE.ERROR_CODE_ITEMS_SELECT.SYSTEM_ERROR;
            }
            finally
            {
                context = null;
            }
        }
    }
}
